package com.example.testapplication;

import android.app.Activity;
import android.app.Application;
import android.os.Bundle;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.ArrayList;
import java.util.List;


public class MyLifecycle implements Application.ActivityLifecycleCallbacks {
    private final List<Activity> activities = new ArrayList<>();

    public List<Activity> getActivities() {
        return activities;
    }

    @Override
    public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle bundle) {
        Log.e("MyLifecycle" , "onActivityCreated");
        activities.add(activity);
    }

    @Override
    public void onActivityStarted(@NonNull Activity activity) {
        Log.e("MyLifecycle" , "onActivityStarted");
    }

    @Override
    public void onActivityResumed(@NonNull Activity activity) {

    }

    @Override
    public void onActivityPaused(@NonNull Activity activity) {

    }

    @Override
    public void onActivityStopped(@NonNull Activity activity) {

    }

    @Override
    public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle bundle) {

    }

    @Override
    public void onActivityDestroyed(@NonNull Activity activity) {
        activities.remove(activity);
    }
}
